--[[/**
-- * 
 * 造成伤害时,吸血
-- *
-- */]]

---@class BuffEffect554101 : BaseBuffEffect
BuffEffect554101 = ClientFight.CreateClass("BuffEffect554101", ClientFight.BaseBuffEffect)
local t = BuffEffect554101

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    if parameters[3] then
    else
        return IBuffEffect.FAIL;
    end
    local result = parameters[3];
    if (not result:isDamage()) then
        return IBuffEffect.FAIL;
    end
    if (not AttackUtils.isDamage(result.state)) then
        return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local addHp = Utils.calcRatio(result.getDamage(), buffEffectValue[1]);
    if (addHp < 1) then
        return IBuffEffect.FAIL;
    end
    local limit = Utils.calcRatio(FighterAttributeManager.getFightAttr(buff.target, FighterAttributeEnum.HP), buffEffectValue[2]);
    if (addHp > limit) then
        addHp = limit;
    end
    local logHp = addHp;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter:%s Buff:%s 吸血: %s",
            fight.frame, buff.target.fighterId, buff.modelId, logHp));
    DamageManager.setFighterHp(fight, buff.target, buff.target, nil, DamageResultTypeEnum.HEAL,
            addHp, buff.target.hp + addHp, false, false, true);
    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()